
<template>
  <div id="oder-list" class="app-container calendar-list-container">
    <!-- 条件查询 -->
    <div class="filter-container">
        
      <el-form :inline="true">
        <el-form-item label="任务令/PO">
          <el-input
            clearable
            v-model="search.EntityName"
          ></el-input>
        </el-form-item>
        <el-form-item>
            <el-button
                type="button"
                class="el-button el-button--primary"
                @click="getList"
            >
                查询</el-button
            >
            <el-button
                type="button"
                class="el-button el-button--warning"
                @click="cancelSubmit"
            >
                取消</el-button
            >
        </el-form-item>
      </el-form>
    </div>

    <!-- 表格 -->
    <el-table
      :data="List"
      border
      v-loading="loading"
      element-loading-text="给我一点时间"
      style="width: 100%;margin-top: 20px"
      :cell-style="{ textAlign: 'center' }"
      :header-cell-style="{ textAlign: 'center' }"
      max-height="700"
    >
      <el-table-column prop="entityName" label="任务令/PO"></el-table-column>
      <el-table-column prop="workNumber" label="工单号"></el-table-column>
      <el-table-column prop="segment2" label="开工时间"></el-table-column>
      <el-table-column prop="segment3" label="回货时间" ></el-table-column>
      <el-table-column prop="segment2" label="上载状态">
        <template slot-scope="scope">
            <div class="fx">
              {{
                scope.row.segment2? "成功": "失败"
              }}
            </div>
          </template>
      </el-table-column>
      <el-table-column prop="materialCode" label="备注"></el-table-column>
      <el-table-column prop="createBy" label="创建人"></el-table-column>
      <el-table-column prop="createDate" label="创建日期"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { GetEntityRevision } from "@/api/processRoute";
export default {
  name: 'emsFind',
  data() {
    return {
      search: {},
      loading: false,
      List: [],
    };
  },
  methods: {
    // 条件查询 取消按钮
    cancelSubmit(){
      this.loading = false
      this.search = {
        EntityName: '',   //加工顺序
      },
      this.getList()
    },
    //获取列表
    getList() {
      this.List = []
      if(!this.search.EntityName) return this.$message.error("任务令不能为空！")
      this.loading = true
      let search1 = Object.assign({},this.search)
      GetEntityRevision(
        search1
      ).then((res) => {
        this.loading = false
        if(res.code == '500') return
        if(res.code != '1') return this.$message.error(res.msg)
        res.data = res.data.replace(/&gt;/g,'>')
        res.data = res.data.replace(/&lt;/g,'<')
        if(res.data.split('<ErrorCode>')[1].split('</ErrorCode>')[0] == '1'){
            this.loading = false
            let msg = res.data.split('<ErrorMsg>')[1].split('</ErrorMsg>')[0]
            return this.$message.error(msg)
        }
        res.data = res.data.split('<LineRow>')
        res.data.splice(0,1)
        let lists = []
        res.data.forEach(item => {
            let obj = {}
            if(item.includes('<Zorgid/>')){ obj.zorgid = '' } 
            else { obj.zorgid = item.split('<Zorgid>')[1].split('</Zorgid>')[0] }

            if(item.includes('<EntityName/>')){ obj.entityName = '' } 
            else { obj.entityName = item.split('<EntityName>')[1].split('</EntityName>')[0] }
            
            if(item.includes('<WorkNumber/>')){ obj.entityName = '' } 
            else { obj.workNumber = item.split('<WorkNumber>')[1].split('</WorkNumber>')[0] }

            if(item.includes('<CreateBy/>')){ obj.createBy = '' } 
            else { obj.createBy = item.split('<CreateBy>')[1].split('</CreateBy>')[0] }

            if(item.includes('<CreateDate/>')){ obj.createDate = '' } 
            else { obj.createDate = item.split('<CreateDate>')[1].split('</CreateDate>')[0] }

            if(item.includes('<Segment2/>')){ obj.segment2 = '' }
            else { obj.segment2 = item.split('<Segment2>')[1].split('</Segment2>')[0] }

            if(item.includes('<Segment3/>')){ obj.segment3 = '' } 
            else { obj.segment3 = item.split('<Segment3>')[1].split('</Segment3>')[0] }

            lists.push(obj)
        });
        console.log(lists)
        this.loading = false
        this.$message.success('查询成功！')
        this.List = lists;
      });
    }
  },
  computed: {},
  mounted() {},
  created() {
    this.getList();
  },
};
</script>

<style lang="scss" scoped>
/deep/ .el-tree-node,
/deep/ .custom-tree-node {
  margin-bottom: 10px;
}
label {
  font-weight: 700;
}
/deep/ .custom-tree-node {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
}
/deep/ .el-dialog__footer {
  text-align: center;
}
.btn-add{
    margin-bottom: 28px;
}
.form-container{
  width: 400px;
}
.save-btn{
  display: flex;
  justify-content: flex-end;
}
.ul-item{
  width: 85%;
}
.re-item{
  width: 100%;
}
.operation-btn{
    margin-bottom: 20px;
}
</style>
